//
//  WYDeleteHonorController.m
//  Boss
//
//  Created by admin on 2018/7/17.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYDeleteHonorController.h"

@interface WYDeleteHonorController ()
@property (strong, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation WYDeleteHonorController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}
-(void)setupUI
{
    self.imageView.image = self.image;
    if (self.isShowDelete) {
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"删除" style:(UIBarButtonItemStyleDone) target:self action:@selector(deletehonor)];
    }
    
    
  //  self.imageView setContentMode:(UIViewContentMode)
    
}
-(void)deletehonor
{
    
    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"您确定要删除吗？" message:nil preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self sureDeleteHonor];
//        WYReportController *rpc = [[WYReportController alloc]init];
//
//        [self.navigationController pushViewController:rpc animated:YES];
    }];
    [alertController addAction:action1];
    [alertController addAction:action2];
    
    [self presentViewController:alertController animated:YES completion:nil];
}
-(void)sureDeleteHonor
{
    [self.dataArray removeObjectAtIndex:self.indexPath.row];
    WEAKSELF
    [WYHttpServer addHonor:[self.dataArray componentsJoinedByString:@","] SucessBlock:^(BOOL success, id response, NSString *errorMessage) {
        if (success) {
            // [weakSelf toast:@"删除成功"];
            [[NSNotificationCenter defaultCenter]postNotificationName:@"refreshMessageDate" object:nil];
            [weakSelf.navigationController popViewControllerAnimated:YES];
        }else{
            [weakSelf toast:errorMessage];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
